package com.video.main_video.manager.apiConfig.userInfo;

import com.video.main_video.manager.handle.userInfo.UpdateAvatarManager;
import com.video.main_video.manager.handle.userInfo.UpdateUserInfoManager;
import com.video.main_video.manager.handle.userInfo.UserInfoManager;
import com.video.main_video.manager.handle.userInfo.UserVideoManager;
import com.video.main_video.manager.handle.videoInfo.VideoGetManager;

import java.util.Objects;

public enum UserInfoEnumApi {

    getVideoList(UserVideoManager.class,"getVideoList",1),
    videoInfoGet(VideoGetManager.class,"videoInfoGet",2),
    updateAvatar(UpdateAvatarManager.class,"updateAvatar",3),
    getUserInfo(UserInfoManager.class,"getUserInfo",4),
    updateUser(UpdateUserInfoManager.class,"updateUser",5),
    ;

    Class name;

    String desc;

    Integer code;

    private UserInfoEnumApi(Class name, String desc,Integer code) {
        this.name = name;
        this.desc = desc;
        this.code=code;
    }


    // 通过code获取名称
    public static Class formName(int code) {
        for (UserInfoEnumApi c : UserInfoEnumApi.values()) {
            if (c.getCode() == code) {
                return c.name;
            }
        }
        return null;
    }

    // 通过code获取名称
    public static Class fromNameByDesc(String desc) {
        for (UserInfoEnumApi c : UserInfoEnumApi.values()) {
            if (Objects.equals(c.getDesc(), desc)) {
                return c.name;
            }
        }
        return null;
    }
    // 通过名称获取code
    public static Integer formCode(Class name) {
        for (UserInfoEnumApi c : UserInfoEnumApi.values()) {
            if (Objects.equals(c.getName(), name)) {
                return c.code;
            }
        }
        return null;
    }

    public Class getName() {
        return name;
    }

    public void setName(Class name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
